/*
 * Created on Sep 23, 2009
 * This software is for the designated users only and contains privileged, proprietary or private information. 
 * Any other use of it is prohibited.  
 */
package com.googlecode.xbeandatasource.common;

import org.apache.commons.jxpath.JXPathContext;


/**
 * @author Johny Huang
 *
 */
public class BeanXpathParser {

	public final static Object parse(Object obj, String expression){
		String vExpression=expression;
		JXPathContext ctx=JXPathContext.newContext(obj);
		String classSimpleName=obj.getClass().getName();
		if(vExpression.startsWith("/"+classSimpleName+"/")){
			vExpression=vExpression.substring(classSimpleName.length()+2);
		}
		return ctx.getValue(vExpression);
	}
}
